<template>
  <div class="setting-container">
    <h5 class="title">主题</h5>
    <div>
      <a-switch
        size="medium"
        v-model="stateData.theme"
        @change="onThemeChange"
        checked-value="light"
        unchecked-value="dark"
      >
        <template #checked> <icon-sun-fill /> </template>
        <template #unchecked> <icon-moon-fill /> </template>
      </a-switch>
    </div>
    <h5 class="title">界面色</h5>
    <div class="themeColor">
      <div class="colorList">
        <div
          v-for="color in store.themeColorList"
          :key="color"
          class="color"
          :style="{ 'background-color': `rgb(var(--${color}-6))` }"
          @click="onThemeColorChange(color)"
        ></div>
      </div>
    </div>
    <h5 class="title">界面功能</h5>
    <div class="configView">
      <div class="item">
        <span>侧边菜单宽度</span>
        <a-input-number
          :modelValue="store.getSiderWidth"
          @change="onSiderWidthChange"
          style="width: 120px"
          :step="10"
          size="small"
        >
          <template #plus>
            <icon-plus />
          </template>
          <template #minus>
            <icon-minus />
          </template>
          <template #suffix> px </template>
        </a-input-number>
      </div>
      <h5 class="title">logo 调整</h5>
      <div class="item">
        <div>
          <a-slider
            v-model="logoHUESlider"
            :max="360"
            :format-tooltip="formatterSlider"
          />
        </div>
      </div>
      <div class="item">
        <span>头部导航展示</span>
        <a-switch size="medium" v-model="headerShow"> </a-switch>
      </div>
      <div class="item">
        <span>标签页展示</span>
        <a-switch size="medium" v-model="tabbarShow"> </a-switch>
      </div>
      <div class="item">
        <span>侧边栏展示</span>
        <a-switch size="medium" v-model="siderShow"> </a-switch>
      </div>
      <h5 class="title">动画控制</h5>
      <div class="item">
        <span>展示进度条</span>
        <a-switch v-model="nProgressShow"> </a-switch>
      </div>
      <div class="item">
        <span>页面过渡动画</span>
        <a-switch v-model="store.animationShow.page"> </a-switch>
      </div>
      <div class="item">
        <span>布局块过渡动画</span>
        <a-switch v-model="store.animationShow.layout"> </a-switch>
      </div>
      <div class="item">
        <span>结果过渡动画</span>
        <a-switch v-model="store.animationShow.result"> </a-switch>
      </div>
      <div class="item">
        <span>加载过渡动画</span>
        <a-switch v-model="store.animationShow.loading"> </a-switch>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import { useThemeStore } from "@/stores/modules/theme.js";
import { storeToRefs } from "pinia";
const store = useThemeStore();
const {
  stateData,
  siderShow,
  headerShow,
  tabbarShow,
  nProgressShow,
  logoHUESlider
} = storeToRefs(store);

const formatterSlider = (value) => {
  return `${value}deg`;
};

function onSiderWidthChange(width) {
  // console.log(width)
  store.setSiderWidth(width);
}

function onThemeColorChange(e) {
  store.setCustomizeColor(e);
}

// 切换 明暗主题
function onThemeChange(e) {
  store.setThemeMode(e);
}
</script>

<style lang="less" scoped>
.setting-container {
  .configView {
    .item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 10px;
      font-size: 14px;
    }
  }
  .themeColor {
    .colorList {
      display: flex;
      flex-wrap: wrap;
      .color {
        width: 20px;
        height: 20px;
        background-color: rgb(var(--red-1));
        margin-right: 10px;
        margin-bottom: 10px;
        cursor: pointer;
        transition: all 0.25s;
        &:hover {
          transform: scale(1.2);
          box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
        }
      }
    }
  }

  .title {
    margin: 10px 0;
    padding: 0;
    font-weight: 500;
  }
}
</style>
